package com.allwees.bs.module.oms.mq.listener;

import com.allwees.bs.module.oms.service.GeneralOmsOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 用户确认收货
 */
@Slf4j
@Component
@RabbitListener(queues = "q.C.Order.Received")
public class OrderReceivedListener {

    @Autowired
    private GeneralOmsOrderService generalOmsOrderService;

    @RabbitHandler
    public void onEvent( String orderItemUuid) {

        long start = System.currentTimeMillis();

        generalOmsOrderService.doReceived(orderItemUuid);

        log.info("order received listener [orderUuid:{}], time: {}ms", orderItemUuid, (System.currentTimeMillis() - start));
    }
}